#ifndef IMAGEMASK_H
#define IMAGEMASK_H

#include <vector>
#include <opencv2/core/core.hpp>

class ImageMask
{
public:
    ImageMask();
    ImageMask(const ImageMask& inputMask);
    ImageMask(const cv::Size& size,unsigned int numberOfLayers);
    
    void create(const cv::Size& size,unsigned int numberOfLayers);
    
    void connectedComponents();
    int largestComponent();
    void visualizeConnectedComponents();

    void boundary();

    void componentBoundary();
    void visualizeComponentsBoundary();
    
    
    cv::Mat applyTo(const std::vector<const cv::Mat*> images);
    cv::Mat applyTo(const cv::Mat* image);
    
    cv::Mat mMask;
    unsigned int mNumberOfLayers;

    std::vector<cv::Point> mBoundary;
    
    int mNumComponents;
    cv::Mat mComponentLabels;
    std::vector<std::vector<cv::Point> > mComponentBoundary;
    
private:
    unsigned int ufFind(unsigned int x, std::vector<unsigned int>& unionFind);
    void ufUnion(unsigned int x, unsigned int y, std::vector<unsigned int>& unionFind);
    
};

#endif // IMAGEMASK_H
